#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int N = 0;
    char gender = 0;
    double hight = 0.0;
    double ret = 0;
    scanf("%d", &N);
    getchar();
    for (int i = 0; i < N; i++)
    {
        scanf("%c %lf", &gender,&hight);
        getchar();
        if (gender =='M')
        {
            ret = hight / 1.09;
        }
        else
        {
            ret = hight * 1.09;
        }
        printf("%.2lf\n", ret);
    }
    
    return 0;
}